package com.lq.createPattern.singleton.type7;

public class SingletonTest07 {
    public static void main(String[] args) {
        System.out.println("静态内部类单例模式静态内部类在外部类装载时候不会装载，用到静态内部类的变量时才会装载并且在" +
                "装载时候只装再一次并且是线程安全的所以实现了懒加载和线程安全");
        Singleton singleton = Singleton.getInstance();
        Singleton singleton1 = Singleton.getInstance();
        System.out.println(singleton1 == singleton);
        System.out.println(singleton1.hashCode());
        System.out.println(singleton.hashCode());
    }

}
class Singleton{
    private Singleton(){};

    private static class SingletonInstance{
        private static final Singleton INSTANCE = new Singleton();
    }

    public static Singleton getInstance(){
       return SingletonInstance.INSTANCE;
    }
}
